/**
 * Candidate number: 35834
 */
package tv.starfu.sequencer.gui;

import de.lessvoid.nifty.Nifty;
import de.lessvoid.nifty.NiftyEventSubscriber;
import de.lessvoid.nifty.controls.Controller;
import de.lessvoid.nifty.controls.FocusHandler;
import de.lessvoid.nifty.elements.Element;
import de.lessvoid.nifty.elements.events.NiftyMousePrimaryClickedEvent;
import de.lessvoid.nifty.input.NiftyInputEvent;
import de.lessvoid.nifty.input.NiftyMouseInputEvent;
import de.lessvoid.nifty.screen.Screen;
import de.lessvoid.xml.xpp3.Attributes;
import java.util.Properties;


class PatternStepButtonController implements Controller {
    private Element element;
    private FocusHandler focusHandler;
    private PatternStepButton button;

    public void bind(Nifty nifty, Screen screen, Element element, Properties parameter, Attributes controlDefinitionAttributes) {
        this.element = element;
        this.focusHandler = screen.getFocusHandler();
     //   this.button = screen;
    }

    public void init(Properties parameter, Attributes controlDefinitionAttributes) {
        
    }

    public void onStartScreen() {
        
    }

    public void onFocus(boolean getFocus) {
        
    }

    public boolean inputEvent(NiftyInputEvent inputEvent) {
        if (inputEvent == NiftyInputEvent.NextInputElement) {
          focusHandler.getNext(element).setFocus();
          return true;
        } else if (inputEvent == NiftyInputEvent.PrevInputElement) {
          focusHandler.getPrev(element).setFocus();
          return true;
        } else if (inputEvent == NiftyInputEvent.Activate) {
          element.onClick();
          return true;
        }
        return false;
    }
    
        
    /* Defines a method that can be called from elemental children */
    public void next(String p1, String p2) {
        System.out.println("Woohoo!! " + p1 + p2);
    }
    
    /* Getting Mouse Coordinates */
    public void nextGrid(int x, int y) {
        System.out.println("nextGrid() clicked at: " + x + ", " + y);
    }
    
    /* MouseOver colour change */
    public void callMe(Element e, NiftyMouseInputEvent ev) {
        String id = e.getId();
        System.out.println("I can fly!" + id);
    }
    
    // Listen to Nifty Mouse Click Events at all elements whose id begins with "drum"
    // pattern : a regular expression identfying participating elements
    // id : elementID of the publisher
    @NiftyEventSubscriber(pattern="psb.*")
    public void onClick(String id, NiftyMousePrimaryClickedEvent event) {
        System.out.println("Element with ID[" + id + "] clicked at [" + event.getMouseX() + ", " + event.getMouseY()+ "]");
        
        // Update Model/Patterns
    }
   // @NiftyEventSubscriber(id="")
    
    
}
